Skip to main content

Haptic Feedback APIs

Enhanced user experience through haptic feedback with multiple intensity levels and contextual feedback types for universal apps.

useHapticFeedback() Hook

Hook-based haptic feedback with availability checking and multiple intensity levels for enhanced user experience.

Feedback TypeUsageDescription
🔹 light"light"Light haptic feedback - subtle vibration
🔸 medium"medium"Medium haptic feedback - moderate vibration
🔶 heavy"heavy"Heavy haptic feedback - strong vibration
success"success"Success haptic feedback - positive confirmation
⚠️ warning"warning"Warning haptic feedback - attention alert
error"error"Error haptic feedback - negative feedback

requestHapticFeedback() Function

Promise-based function for explicit haptic feedback requests with detailed success/failure handling.

PropertyInputOutputDescription
requestHapticFeedbackfeedbackType?: stringPromise<string>Function to request haptic feedback with specified type. Returns promise that resolves with "SUCCESS" status or rejects with error message if haptic feedback fails. Types: "light", "medium", "heavy", "success", "warning", "error"

Platform & Device Behavior

Haptic feedback API behavior varies across different platforms and device types. Hardware capabilities affect intensity and feedback quality.

PlatformStatusBehaviorNotes
🤖 Android Emulator🔄 LimitedHaptic feedback simulated through system vibration. Limited intensity variation.Android emulator provides basic vibration simulation only
🤖 Android Physical✅ SupportedComplete haptic feedback with all intensity levels and contextual feedback types.Requires vibration permission. Hardware-dependent intensity levels.
🍎 iOS Simulator⏳ Coming SooniOS haptic feedback functionality currently in development.Haptic feedback features not yet implemented for iOS Simulator
🍎 iOS Physical⏳ Coming SooniOS haptic feedback functionality currently in development.Native Taptic Engine integration planned for future release
🌐 Web Browser🔄 FallbackVibration API where supported, otherwise silent fallback.Browser security restrictions. Limited to vibration pattern API.

🎛️ Interactive Demo

Customize the haptic feedback demo by selecting different feedback types and properties.

ButtonFeedbackDemo.js
1import React from 'react';
2import { useHapticFeedback } from "catalyst-core/hooks";
3
4function ButtonFeedbackDemo() {
5 const {
6 // New standardized interface
7 execute: executeHaptic,
8 isSupported
9 } = useHapticFeedback();
10
11 return (
12 <div style={{ padding: '20px', maxWidth: '500px' }}>
13 <h2>🔘 Button Feedback Demo</h2>
14
15 {/* Device availability check */}
16 {isSupported ? (
17 <p style={{ color: 'green', marginBottom: '20px' }}>
18 ✅ Haptic feedback is available on this device
19 </p>
20 ) : (
21 <p style={{ color: 'red', marginBottom: '20px' }}>
22 ❌ Haptic feedback is not available on this device
23 </p>
24 )}
25
26 {/* Haptic feedback buttons */}
27 <div style={{
28 display: 'grid',
29 gridTemplateColumns: 'repeat(auto-fit, minmax(120px, 1fr))',
30 gap: '1rem',
31 marginBottom: '20px'
32 }}>
33 <button onClick={() => executeHaptic('light')}>🔹 Light</button>
34 <button onClick={() => executeHaptic('medium')}>🔸 Medium</button>
35 <button onClick={() => executeHaptic('heavy')}>🔶 Heavy</button>
36 <button onClick={() => executeHaptic('success')}>✅ Success</button>
37 <button onClick={() => executeHaptic('warning')}>⚠️ Warning</button>
38 <button onClick={() => executeHaptic('error')}>❌ Error</button>
39 </div>
40 </div>
41 );
42}
43
44export default HapticFeedbackApp;

Important Notes

  • Platform Support: Works on iOS and Android devices with haptic capabilities
  • Availability Check: Always check `isAvailable` before using haptic feedback
  • User Preferences: Respects system-level haptic feedback settings
  • Battery Optimization: Use haptic feedback judiciously to preserve battery life
  • Contextual Usage: Use appropriate feedback types (success, error, warning) for better UX
  • Web Fallback: Returns safe defaults and false availability when running in web mode